package com.itheima.ifswitch;

import java.util.Scanner;

public class IfTest {

    public static void main(String[] args) {
        switchTest2();
    }

    public static void ifTest() {
        int score;
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入分数：");
        score = scanner.nextInt();
        if (score >= 90) {
            System.out.println("优秀");
        } else if (score >= 80) {
            System.out.println("良好");
        } else if (score >= 70) {
            System.out.println("一般");
        } else {
            System.out.println("差");
        }
    }
    public static void switchTest() {
        int score;
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入分数：");
        score = scanner.nextInt();
        switch (score / 10) {
            case 10:
                System.out.println("满分");
                break;
            case 9:
                System.out.println("优秀");
                break;
            case 8:
                System.out.println("良好");
                break;
            case 7:
                System.out.println("一般");
                break;
            default:
                System.out.println("差");
        }
    }

    public static void switchTest2() {
        //jdk14+版本写法
        int score;
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入分数：");
        score = scanner.nextInt();
        switch (score / 10) {
            case 10, 9 -> System.out.println("优秀");
            case 8 -> System.out.println("良好");
            case 7 -> System.out.println("一般");
            default -> System.out.println("差");
        }
    }
}
